package com.example.base.plugin.moudel;

import com.example.base.app.AppFunction;
import com.example.base.security.domain.SysRoleEntity;
import com.example.base.security.service.SysRoleService;
import com.example.base.utils.Result;
import com.example.base.utils.SpringContextUtils;

import java.util.Map;

public class SysRoleNoPlugin implements AppFunction {
    @Override
    public String getAppFunctionName() {
        return "getSysRoleByRoleNo";
    }

    @Override
    public Object appFunction(Map<String, Object> objectMap) {
        if(!objectMap.containsKey("roleNo")){
            return Result.errorInfo("角色编号不得为空");
        }
        SysRoleService sysRoleService= SpringContextUtils.getBean(SysRoleService.class);
        SysRoleEntity sysRoleEntity=sysRoleService.getSysRoleEntityByRoleNo(String.valueOf(objectMap.get("roleNo")));
        return Result.successInfo(sysRoleEntity);
    }
}
